<?php 


require "../common/Curl.php";

/**
 *	https=>//open.esign.cn/doc/detail?id=opendoc%2Fpaas_api%2Fsgv49u&namespace=opendoc%2Fpaas_api
 * 	电子签名SaaS API非标版
 * 	区块链核验 +  辅助接口  +  历史接口  ----接口顺序排列封装
 *  使用请求签名鉴权方式
 *  下一个------------------ 
 */



//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/**
 * [querySignAntPushInfo 查询签署文件上链信息]
 * @param  [type] $flowId [description]
 * @param  [type] $appId  [description]
 * @param  [type] $secret [description]
 * @param  [type] $url    [description]
 * @return [type]         [description]
 */
function querySignAntPushInfo($flowId,$appId,$secret,$url){
	$urlss = $url."/v1/querySignAntPushInfo";
	$head_url = "/v1/querySignAntPushInfo";
    $data = [
		"flowId"=>$flowId
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}
// $flowId = "2645a6c581dd77fdd70b566399079e29";
// $a = querySignAntPushInfo($flowId,$appId,$secret,$url);
// var_dump($a);die;


//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/**
 * [checkAntfinNotary 核验签署文件上链信息]
 * @param  [type] $docHash   [description]
 * @param  [type] $antTxHash [description]
 * @param  [type] $appId     [description]
 * @param  [type] $secret    [description]
 * @param  [type] $url       [description]
 * @return [type]            [description]
 */
function checkAntfinNotary($docHash,$antTxHash,$appId,$secret,$url){
	$urlss = $url."/v1/checkAntfinNotary";
	$head_url = "/v1/checkAntfinNotary";
    $data = [
		"docHash"=>$docHash,
		"antTxHash"=>$antTxHash
	];
    $res = json_encode($data);
    $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
    $result = sendHttp($method="POST",$urlss,$header,$res);
    return $result;
}
// $docHash = "e3d635871f5f2deb2******0f0a90a58a039ee3";
// $antTxHash = "d8f5caf9910ad812f0******bcb798ff3635eb3";
// $a = checkAntfinNotary($docHash,$antTxHash,$appId,$secret,$url);
// var_dump($a);die;


//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// 辅助接口 搜索关键字坐标

/**
 * [searchWordsPosition 搜索关键字坐标]
 * @param  [type] $fileId   [description]
 * @param  [type] $keywords [description]
 * @param  [type] $appId    [description]
 * @param  [type] $secret   [description]
 * @param  [type] $url      [description]
 * @return [type]           [description]
 */
function searchWordsPosition($fileId,$keywords,$appId,$secret,$url){
	$urlss = $url."/v1/documents/".$fileId."/searchWordsPosition?keywords=".$keywords;
	$head_url = "/v1/documents/".$fileId."/searchWordsPosition?keywords=".$keywords;
	$data =[];
    $res = json_encode($data);
    $header = getHeader($data,"GET",$head_url,$appId,$secret);
    $result = sendHttp($method="GET",$urlss,$header,$res);
    return $result;
}
// $fileId = "aacf725655f24c5598fc870799626769";
// $keywords = "1,2";
// $a = searchWordsPosition($fileId,$keywords,$appId,$secret,$url);
// var_dump($a);die;


//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// 历史接口   搜索关键字坐标  不能用

// function searchWordsPositionHistory($flowId,$fileId,$keywords,$appId,$secret,$url){
// 	$urlss = $url."/v1/signflows/".$flowId."/documents/".$fileId."/searchWordsPosition?keywords=".$keywords;
// 	$head_url = "/v1/signflows/".$flowId."/documents/".$fileId."/searchWordsPosition?keywords=".$keywords;
//     $data = [
// 		"flowId"=>$flowId,
// 		"fileId"=>$fileId,
// 		"keywords"=>$keywords
// 	];
//     $res = json_encode($data);
//     $header = getHeader($data,"POST",$head_url,$appId,$secret,$url);
//     $result = sendHttp($method="POST",$urlss,$header,$res);
//     return $result;
// }
// $flowId = "2645a6c581dd77fdd70b566399079e29";
// $fileId = "2645a6c581dd77fdd70b566399079e29";
// $keywords = "1,2";
// $a = searchWordsPositionHistory($flowId,$fileId,$keywords,$appId,$secret,$url);
// var_dump($a);die;




